﻿using AutoMapper;
using Nop.Admin.Models.ShareBuy;
using Nop.Core.Domain.ShareBuy;

namespace Nop.Admin
{
    public static class MappingExtensionsShare
    {
        #region ShareBuy
        public static ShareBuyItemModel ToModel(this ShareBuyItem entity)
        {
            ShareBuyItemModel model = new ShareBuyItemModel();
            model.Comments = entity.ShareBuyComments.Count;
            model.CreatedOnUtc = entity.CreatedOnUtc;
            model.Description = entity.Description;
            model.Id = entity.Id;
            model.Likes = entity.ShareBuyVotes.Count;
            model.Title = entity.Title;
            model.UpdatedOnUtc = entity.UpdatedOnUtc;
            return model;
        }

        public static ShareBuyItem ToEntity(this ShareBuyItemModel model)
        {
            return Mapper.Map<ShareBuyItemModel, ShareBuyItem>(model);
        }
        #endregion

    }
}